//
//  YUHomeCollectionViewCell.swift
//  tuniu
//
//  Created by 于世民 on 2019/8/15.
//  Copyright © 2019 于世民. All rights reserved.
//

import UIKit

fileprivate struct Metric {
    
    static let margin : CGFloat = 10
    static let scale : CGFloat = 18 / 13
    static let column: CGFloat = 3
}

class YUHomeCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var titleLabel: UILabel!
    
    var item: YUAdvertisesModel? { didSet { setItem() } }
    
    static var rowHeight: CGFloat = 0
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        backgroundColor = UIColor.red
    }
    
    func setItem() {
        
        guard let item = self.item else { return }
        titleLabel.text = item.title
        
        YUHomeCollectionViewCell.rowHeight = CGFloat(item.title.count)
    }
    
    static func itemMargin() -> CGFloat {
        
        return Metric.margin
    }
    
    static func itemSize() -> CGSize {
        // 结合 FlowLayout 设置
        let width = kScreenW
        let height = CGFloat(200)
        
        return CGSize(width: width, height: height)
    }

}
